package com.software.graduationproject.commons.exception;

import com.software.graduationproject.commons.enums.ResultCodes;
import com.v2coding.validate.BaseResultCode;

public class ServiceException extends RuntimeException {
    private BaseResultCode code;

    public ServiceException(String message) {
        super(message);
        this.code = ResultCodes.FAILURE_SERVICE_ERROR;
    }

    public ServiceException(String message, Throwable cause) {
        super(message, cause);
        this.code = ResultCodes.FAILURE_SERVICE_ERROR;
    }

    public ServiceException(BaseResultCode code) {
        super(code.getMessage());
        this.code = code;
    }

    public ServiceException(BaseResultCode code, String message) {
        super(message);
        this.code = code;
    }

    public ServiceException(BaseResultCode code, Throwable cause) {
        super(code.getMessage(), cause);
        this.code = code;
    }

    public Throwable fillInStackTrace() {
        return this;
    }

    public Throwable doFillInStackTrace() {
        return super.fillInStackTrace();
    }

    public BaseResultCode getCode() {
        return this.code;
    }
}
